<template>
	<view class="min100 plr-30 pb-100 bg " :style="{paddingTop:blindBoxheight+'rpx'}">
		<view class="text-center mt-30 size-38" style="font-weight: 600;">发现</view>
		<view class="flex radius-45 ptb-12 plr-10">
			<view class=" flex toptitbox flex-between">
				<view class="flex radius-45 plr-10 tabbox">
					<view :class="['ptb-20','mlr-10','midItem',midIndex==0?'midActive':'']" @click="changeMid(0)">
						平台公告
						<view class="line" v-if="midIndex==0"></view>
					</view>
					<view :class="['ptb-20','mlr-10','midItem',midIndex==1?'midActive':'']" @click="changeMid(1)">
						新闻发声
						<view class="line" v-if="midIndex==1"></view>
					</view>
					<view :class="['ptb-20','mlr-10','midItem',midIndex==2?'midActive':'']" @click="changeMid(2)">
						辟谣墙
						<view class="line" v-if="midIndex==2"></view>
					</view>
				</view>
				<view class="">
					<image src="../../static/mark/Refresh.png" class="topIcon" mode="">
				</view>
			</view>
		</view>
		<view class="" v-if="isshow==0">
			<view class="searchbox flex flex-start mt-20">
				<view class="searchimg">
					<image src="../../static/mark/search.png" mode="widthFix" @click="handlesearch()"></image>
				</view>
				<view class="selectbox ml-10 flex flex-between">
					<view v-for="item in select_list"
						:class="['plr-20','ptb-12',item.active==true?'selectitem':'selectitem1']"
						@click="navigation(item)">{{item.name}}</view>
				</view>
			</view>
			<view class="contbox ptb-20">
				<view class="market_list" style="" v-for="item in notice_list" @click="tonotice(item.id)">
					<view class="" style="width: 58%;">
						<view class="market_list_title fw" style="">
							{{item.title}}
						</view>
						<view class="flex1 size-20 market_list_category_name" style="">
							<view class="market_list_category_name_left">
								{{item.category_name}}
							</view>
							<view class="">
								{{item.create_time}}
							</view>
						</view>
					</view>
					<view class="rightbox">
						<image class="photo" :src="item.image" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="isshow==1">
			<view class="searchbox flex flex-start mt-20">
				<view class="selectbox flex ml-10" v-for="item in Journalism_list">
					<view :class="['plr-20','ptb-12',item.active==true?'selectitem':'selectitem1']"
						@click="navigation(item)">{{item.name}}</view>
				</view>
			</view>
			<view class="contbox ptb-20">
				<view class="contentitem ptb-20" v-for="item in journalismarr" @click="toWebsite(item.id)">
					<view class="imgbox">
						<image :src="item.image" mode="widthFix"></image>
					</view>
					<view class="contenttit mt-20 size-26 ">{{item.title}}</view>
					<view class="tipsbox flex">
						<view class="tipsborder plr-10">{{item.category_name}}</view>
						<view class="timebox">{{item.create_time}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="isshow==2">
			<view class="putQuestions">
				<view class="putitem pt-30" v-for="item in putarr" @click="toRumor(item)">
					<view class="putUser size-26">
						<view class="userInfo flex">
							<view class="flex flex-start">
								<image mode="" :src="item.head_image==''?yes:item.head_image"
									style="border-radius: 50%;width: 70rpx;height: 70rpx;"></image>

								<view class="">{{item.is_anonymous==0 ? item.uname:'匿名提交'}}</view>

							</view>
							<view class="putTime">{{item.create_time}}</view>
						</view>
						<view class="putCont plr-60 ptb-20">
							<view class="">{{item.remark}}</view>
							<view class="imagearr mt-20">
								<image v-for="item in item.images" :src="item" mode="aspectFit"></image>
							</view>
						</view>
					</view>
					<view class="official mtb-30 flex">
						<image src="../../static/market/zi.png" mode="widthFix"></image>
						官方回复：<view class="reply">{{item.reply}}</view>
					</view>
				</view>
			</view>
			<view class="questionbox white flex pr-30" @click="toquestions">
				<view class="add_question">
					<image src="../../static/mark/k3.png"></image>
				</view>
				我要提问
			</view>
		</view>

		<tab></tab>
	</view>
</template>

<script>
	import {globalData} from "@/App.vue"
	import empty from "../../components/empty.vue"
	import tab from "../../components/tab.vue"
	export default {
		components: {
			empty,
			tab
		},
		data() {
			return {
				blindBoxheight:'',
				active: true,
				yes: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F69%2F80%2F595f67c3a6eb1_610.jpg&refer=http%3A%2F%2Fbpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1670924185&t=665c6712e5d2b7c2be9929c754f26e28',
				no: '',
				item: '',
				// 辟谣墙列表
				putarr: [

				],

				isshow: 0,
				// 平台公告列表
				notice_list: [],
				// 平台公告分类
				select_list: [],
				// 新闻发声列表
				journalismarr: [],
				// 新闻发声分类
				Journalism_list: [],
				poparr: [],
				show: false,
				rowStyle: 2,
				flag: false, //上拉加载
				midIndex: 0,
				query: {
					page: 1,
					pagesize: 10,
					search: "",
					time_order: '',
					price_order: '',
				},
				status: 'more',
				list: [],
				goods_id: [],
				wall: '',
			}
		},
		onLoad() {
			let _that = this;
			uni.getSystemInfo({
				success(e) {
					console.log(e.statusBarHeight, '123122222222222222222222');
					if (e.platform == "ios" || e.platform == "devtools") {
						_that.blindBoxheight = e.statusBarHeight + 45;
					} else {
						_that.blindBoxheight = e.statusBarHeight + 50;
					}
				}
			})
			console.log(getApp().globalData);
		},
		onShow() {
			this.init();
			// tisshow=0,
			this.discoveryClassification()
			this.newsOccurrence()
			// 公告初渲染
			this.$http('api/index/noticeList/', this.query).then(res => {
				this.notice_list = res
				// console.log(this.notice_list);
			})



		},
		onHide() {
			this.midIndex = 0;
			this.flag = false;
			this.status = 'more';
			this.list = [];
			this.query = {
				page: 1,
				pagesize: 10,
				search: "",
				time_order: '',
				price_order: ''
			}
		},
		onReachBottom() {
			if (this.wall >= this.query.pagesize) {
				this.feedBackList()
			} else {
				console.log(1);
			}
		},

		methods: {
			handlesearch() {
				uni.navigateTo({
					url: '/pages/market/marketSearch'
				})
			},
			feedBackList() {
				// 辟谣墙初渲染
				this.$http('api/user/feedBackList', this.query).then(res => {
					res.forEach((item) => {
						this.images = item.images
						// console.log( this.images);
					})
					this.putarr = this.putarr.concat(res)
					this.query.page++
					this.wall = res.length
					console.log(this.wall);
					console.log(this.putarr);
				})
			},
			// 新闻发生分类
			newsOccurrence() {
				this.$http('api/index/newsCategoryList').then(res => {
					let arr = JSON.parse(JSON.stringify(res))
					arr[0].active = true
					this.Journalism_list = arr
				})
			},
			// 平台公告分类
			discoveryClassification() {
				this.$http('api/index/noticeCategoryList', this.query).then(res => {
					// this.select_list = res
					let arr = JSON.parse(JSON.stringify(res))
					arr[0].active = true
					this.select_list = arr

				})
			},

			toRumor(item) {
				var item = JSON.stringify(item)
				uni.navigateTo({
					url: '/pages/market/rumor_detail?item=' + item
				})
			},
			// 新闻发声列表跳转
			toWebsite(id) {
				console.log(id);
				uni.navigateTo({
					url: '/pages/market/newDetail?id=' + id
				})

			},
			// 平台公告列表跳转
			tonotice(id) {
				console.log(id);
				uni.navigateTo({
					url: '/pages/market/noticeDetail?id=' + id
				})
			},
			// 辟谣墙跳转
			toquestions() {
				uni.navigateTo({
					url: '/pages/market/question'
				})
			},
			// 二级tab点击
			navigation(item) {
				console.log(item)
				if (this.isshow == 0) {
		 
					this.id = item.id
					this.$http('api/index/noticeList', {
						category_id: this.id
					}).then(res => {
						this.notice_list = res
						console.log(this.notice_list);

					})

					for (let i = 0; i < this.select_list.length; i++) {
						this.select_list[i].active = false
					}

					item.active = true
				} else if (this.isshow == 1)
			 
					this.id = item.id
				this.$http('api/index/newsList', {
					category_id: this.id
				}).then(res => {
					this.journalismarr = res

				})

				for (let i = 0; i < this.Journalism_list.length; i++) {
					this.Journalism_list[i].active = false
				}
				item.active = true

			},


			// 选择平台公告还是新闻发生还是辟谣墙
			changeMid(index) {
				this.isshow = index
				this.midIndex = index;
				if (this.midIndex == 0) {
					// 公告初渲染
					this.$http('api/index/noticeList/', this.query).then(res => {
						this.notice_list = res
						// console.log(this.notice_list);
					})

				} else if (this.midIndex == 1) {
					// 新闻初渲染
					this.$http('api/index/newsList', this.query).then(res => {
						this.journalismarr = res
						// console.log(this.notice_list);
					})
				} else if (this.midIndex == 2) {
					// 辟谣墙初渲染
					this.$http('api/user/feedBackList', this.query).then(res => {
						res.forEach((item) => {
							this.images = item.images
							// console.log( this.images);
						})
						this.putarr = this.putarr.concat(res)
						this.query.page++
						this.wall = res.length
						console.log(this.wall);
						console.log(res);
					})
				}
				this.list = [];
				this.query = {
					page: 1,
					pagesize: 10,
					search: "",
					time_order: '',
					price_order: ''
				};

			},
			init() {
				if (this.midIndex == 0) {
					this.$http('api/index/noticeList', this.query).then(res => {

					})
				} else {
					this.$http('api/index/newsCategoryList').then(res => {
						this.Journalism_list = res
						console.log(this.Journalism_list);
					})

				}

			},


		}
	}
</script>
<style lang="less" scoped>
	.market_list_category_name_left {
		background-color: #ECECEC;
		width: 130rpx;
		height: 50rpx;
		text-align: center;
		line-height: 50rpx;
		margin: -14rpx 0 0 0;
	}

	.market_list_category_name {
		justify-content: space-between;
		margin: 30rpx 0 0 0;
	}

	.market_list_title {
		height: 80rpx;
		width: 400rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;


	}

	.market_list {
		display: flex;
		justify-content: space-between;
		border-bottom: 3rpx solid #E0E0E0;
		margin: 0px 0px 40px 0;
		height: 180rpx;
	}

	.putQuestions {
		.putitem {
			.putUser {
				border-bottom: 1rpx solid rgb(227, 227, 227);

				.userInfo {
					color: #999;

					image {
						width: 40rpx;
						height: 40rpx;
						margin-right: 20rpx;
					}
				}

				.putCont {
					.imagearr {
						;
						display: flex;
						width: 100%;

						image {
							width: 100px;
							height: 100px;
							// position: absolute;
							// top: -50%;
						}
					}
				}
			}

			.official {
				image {
					width: 40rpx;
					height: 40rpx;
					margin-right: 20rpx;
				}

				.reply {
					color: rgb(223, 97, 46);
					display: inline-block;
					white-space: nowrap;
					width: 67%;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}

		}
	}

	.questionbox {
		// border: 1rpx solid red;
		width: 240rpx;
		height: 70rpx;
		line-height: 70rpx;
		border-radius: 40rpx;
		background: linear-gradient(90deg, #fff, #000);
		position: fixed;
		bottom: 14%;
		right: 8%;

		.add_question {
			width: 70rpx;
			height: 70rpx;
			border-radius: 50%;
			background-color: #000;

			image {
				// border: 1rpx solid red;
				width: 100%;
				height: 100%;
			}
		}
	}

	.contbox {
		.contentitem {
			border-bottom: 1rpx solid #E0E0E0;

			.imgbox {
				height: 220rpx;
				overflow: hidden;

				image {
					width: 100%;
				}
			}

			.leftbox {
				.text_title {
					font-weight: 600;
				}

				.tipsbox {
					margin-top: 100rpx;
					font-size: 12rpx;

					.tipsborder {
						border: 1rpx solid rgb(108, 126, 205);
						border-radius: 10rpx;
						color: rgb(108, 126, 205);
						background-color: rgb(239, 246, 255);
					}
				}
			}

			.contenttit {
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.tipsbox {
				margin-top: 16rpx;
				font-size: 12rpx;

				.tipsborder {
					border: 1rpx solid rgb(108, 126, 205);
					border-radius: 10rpx;
					color: rgb(108, 126, 205);
					background-color: rgb(239, 246, 255);
				}
			}
		}
	}

	.searchbox {
		.searchimg {
			width: 60rpx;
			height: 40rpx;
			border-right: 1rpx solid #999;

			image {
				width: 40rpx;
			}
		}

		.selectbox {
			display: flex;
			overflow: auto;

			.selectitem,
			.selectitem1 {
				flex-grow: 0;
				flex-shrink: 0;
				font-size: 16rpx;
				color: #999;
				margin: 0 10rpx;
				border-radius: 40rpx;
				background-color: rgb(246, 246, 246);
			}

			.selectitem {
				color: #fff;
				background-color: rgb(0, 203, 211);
			}
		}
	}

	.toptitbox {
		width: 100%;
		border-bottom: 1rpx solid #f6f6f6;
	}

	.rightbox {
		width: 260rpx;
		background-color: aqua;
		height: 140rpx;
	}

	.imagebox {
		position: relative;

		.lockimg {
			position: absolute;
			top: 0;
			width: 80%;
			z-index: 999;
			left: 10%;
		}

		.itemTwoImg {
			width: 330rpx;
			height: 290rpx;
			border-radius: 20rpx;

		}

		.authorinfo {
			width: 100%;
			position: absolute;
			top: 20%;
			z-index: 999;
			text-align: center;

			.authname {
				font-size: 36rpx;
			}
		}

	}

	::v-deep  .u-action {
		color: #fff !important;
	}

	.homeImg {
		width: 284rpx;
		height: 60rpx;
	}

	.collectImg {
		width: 100%;
		height: 690rpx;
	}

	.topIcon {
		width: 50rpx;
		height: 50rpx;
	}

	.homeIcon {
		width: 30rpx;
		height: 30rpx;
	}

	.tipsLeft {
		background: #44ACFF;
		color: #2f2f2e;
	}

	.tipsRight {
		background: rgba(239, 170, 28, .3);
	}

	.userImg {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
	}

	::v-deep  .u-action-active {
		color: #fff;
	}

	.midItem {
		width: 120rpx;
		height: 68rpx;
		color: #999;
		font-size: 26rpx;
		text-align: center;
	}

	.midActive {
		// border-bottom: 10rpx solid #44ACFF;
		color: #000;
		font-weight: 600;

		.line {
			width: 40%;
			height: 10rpx;
			position: relative;
			top: 9rpx;
			left: 30%;
			background-color: rgb(0, 203, 211);
		}
	}

	.rowImg {
		width: 36rpx;
		height: 36rpx;
	}

	.indexTwoItem {
		width: 330rpx;
		box-shadow: 0px 0px 10rpx 2rpx rgba(92, 95, 239, 0.1);
		border-radius: 10rpx;
		position: relative;
		font-size: 24rpx;
		color: #999;

		.itemTitle {
			font-weight: 550;
			color: #333;
			height: 100rpx;
		}

		.itemTwoImg {
			width: 330rpx;
			height: 290rpx;
			border-radius: 20rpx;
		}

		.itemTips {
			position: absolute;
			left: 0;
			top: 0;
			background: #5C5FEF;
			border-radius: 20rpx 0px 20rpx 0px;
			color: #fff;
			font-size: 22rpx;
			z-index: 10;
		}

		.authTwoImg {
			width: 20rpx;
			height: 20rpx;
		}
	}
</style>
